<?php
class PaginationOnlyLink {
	public $total = 0;
	public $limit = 20;
	public $append_link_num = 3;
	public $url = '';
	public $style_links = 'links';
	 
	public function render() {
		$total = $this->total;
		
		if (!(int)$this->limit) {
			$limit = 10;
		} else {
			$limit = $this->limit;
		}

        $append_link_num = $this->append_link_num;
		$num_pages = ceil($total / $limit);
		
		$output = '';

		if ($num_pages > 1) {
			$end = $num_pages;

            $output = '<img src="catalog/view/theme/default/image/post/icon_pages.gif" width="11" height="12" />&nbsp;';
            if($num_pages>$append_link_num+1){
                $output .= '<a href="' . str_replace('{page}', 1, $this->url) . '">1</a>  .... ';

                for ($i = ($num_pages-$append_link_num+1); $i <= $end; $i++) {
                    $output .= ' <a href="' . str_replace('{page}', $i, $this->url) . '">' . $i . '</a> ';
                }
            }else{
                for ($i = 1; $i <= $end; $i++) {
                    $output .= ' <a href="' . str_replace('{page}', $i, $this->url) . '">' . $i . '</a> ';
                }
            }
		}
		
		return ($output ? '<div class="' . $this->style_links . '">' . $output . '</div>' : '');
	}
}
?>